﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace AutoCAD_CSharp_plug_in3.Chap01
{
    public partial class PipeSplitForm : Form
    {
        public PipeSplitForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var circleChecked = checkBox1.Checked;
            var insertChecked = checkBox2.Checked;
            var lineChecked = checkBox3.Checked;
            if (!circleChecked && !insertChecked && !lineChecked)
            {
                MessageBox.Show(@"请选择一种打断方式！", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                var enableLineIntert = false;

                var selected = new List<string>(3);
                if (circleChecked) selected.Add(nameof(BreakType.Circle));
                if (insertChecked) selected.Add(nameof(BreakType.Insert));
                if (lineChecked) enableLineIntert = true;
                selected.Add(nameof(BreakType.Line));
                selected.Add(nameof(BreakType.Polyline));
                Hide();
                LineBreakAction.ProcessSelectedObj(selected, enableLineIntert);
            }
            finally
            {
                Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}